Skip to content

net: connection: Unconditionally forward packets when handling packet sockets #93246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ClaCodes
Copy link
Contributor

When handling packets for inputing into raw-packet-sockets, unconditionally
forward them to upper layer, so that it can be handled by L2-handlers.

Based on: #93050
Fixes: #93245

* with this packet regardless the result.
*/
raw_pkt_continue = true;
continue; /* L2 not processed yet */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need to continue here (skip this "connection") if the condition is satisfied? We don't want to report raw packets to datagram packet sockets.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@@ -713,6 +705,11 @@ enum net_verdict net_conn_packet_input(struct net_pkt *pkt, uint16_t proto, enum

k_mutex_unlock(&conn_lock);

/* We shall continue with raw packets regardless the result. */
if (type == SOCK_RAW) {
raw_pkt_continue = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, when working with packet sockets I found this raw_pkt_continue quite fishy and I'm tempted to suggest we should just get rid of it. It seems a bit odd that packet socket, which delivers packet clones anyway, makes a decission whether the net stack should proceed with packet processing or not, it seems quite error prone (as this example shows).

Especially that with generalized L3 handling, it seems that the same issue will arise with packets delivered at the DGRA level. IMHO we should just return NET_CONTINUE here unconditionally and let the net stack decide how to proceed with the packet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully agree.

Can we even make them return void instead of NET_CONTINUE?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API's internal so we could update the function signature too.

@ClaCodes ClaCodes force-pushed the fix/packet_sockets branch 3 times, most recently from e69c9a8 to c61f82f Compare July 18, 2025 04:20
ClaCodes added 3 commits July 18, 2025 06:39
Store the flag in the packet meta-data so that processing may be deferred
if necessary.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
Use the l2_processed-flag to decide whether a network packet needs to be
processed by an L2-handler. This could be used in the future to requeue
packets for later processing by a different traffic class queue.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
Specify the socket type, when inputing a packet into a packet-socket.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
@ClaCodes ClaCodes force-pushed the fix/packet_sockets branch from c61f82f to 64dc2b6 Compare July 18, 2025 04:42
@ClaCodes ClaCodes requested a review from rlubos July 18, 2025 04:42
When handling packets for inputing into packet-sockets, unconditionally
forward them, so that they may be handled by the rest of the network
stack after.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
Copy link

Copy link
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting -1 so that this is not merged accidentally. I am not able to do a proper review atm, but will return to this after returning from vacation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

net: connection: Packet sockets cause packets to drop
5 participants